package sample.duplicate;
import java.lang.instrument.Instrumentation;
import java.util.Properties;


public class MyAgent {
	
//	public static Instrumentation inst = null;
//	
//	public static void premain(String agentArgs, Instrumentation inst) {
//		MyAgent.inst = inst;
//		System.out.println("MyAgent2.premain: agentArgs =" + agentArgs);
//		System.out.println("MyAgent2.premain: inst =" + inst);
//	}
//	
//	public static Instrumentation getInst() {
//		return inst;
//	}
	
	  private static final String KEY = "my.instrumentation";
	    public static void premain(String options, Instrumentation inst) {
	        Properties props = System.getProperties();
	        if(props.get(KEY) == null)
	           props.put(KEY, inst);
	    }

	    public static Instrumentation getInstrumentation() { 
	       return (Instrumentation) System.getProperties().get(KEY);
	    }

}
